from django.utils.translation import ugettext_lazy as _
from sitepal.sitebase.conf    import properties

def render_body(self,content=None,attributes={}):
    return self.render_tag('body',self.escape(content),attributes)

def render_html(self,title=None,content=None,attributes={}):
    context = self.common_context()
    context.update({
        'body'   : self.render_body(content,attributes),
        'headers': self.safe("\n".join(self.theme.headers)),
        'title'  : self.escape(title) or u'',
    })
    return self.render_template('theme/html.html',context)

def render_page(self,request=None,layout=None,content=None,title=None):
    if layout:
        output = []
        if request:
            request.main_content = content
        for region in layout.regions:
            output.append(region.render(self.theme,request))
        content = self.safe(u''.join(output))
    attributes = {
        'id'   : 'id_page',
        'class': 'page container_24 clearfix'
    }
    return self.render_tag('div',content,attributes,allow_empty=True)
